package whf.framework.lucene;

import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;

import whf.framework.config.ApplicationConfig;
import whf.framework.util.StringUtils;
import whf.framework.util.Utils;

/**
 * @author king
 * @create 2008-1-24 下午03:37:03
 * 
 */
public class IndexConfig {
	
	public static String getIndexDirectory() {
		String dir = ApplicationConfig.getInstance().getValue("index.directory");
		java.io.File file = new java.io.File(dir);
		if(!file.exists() || !file.isDirectory()) {
			file.delete();
			Utils.mkdir(dir);
		}
		return dir;
	}
	
	public static IndexMode getIndexMode() {
		String mode = ApplicationConfig.getInstance().getValue("index.mode");
		if(StringUtils.equalsIgnoreCase("auto", mode)) {
			return IndexMode.AUTO;
		} else {
			return IndexMode.MANUAL;
		}
	}
	
	public static Analyzer getAnalyzer() {
		return new StandardAnalyzer();
	}
	
	public static enum IndexMode{
		AUTO, 
		MANUAL;
	}
}
